package com.nian.db.mysql.mycat.simple.dao;

import com.nian.db.mysql.mycat.simple.model.MyCatUser;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用途：
 * 开发：zhangmj
 * 日期：2020/4/16 0016 16:27
 */
@Repository
public interface MyCatUserRepository extends JpaRepository<MyCatUser, Long> {

    MyCatUser findByCode(String code);

    @Transactional
    @Modifying
    @Query(value=" insert into user (code, name, remark, id) values (:#{#model.code} , :#{#model.remark}, :#{#model.remark}, :#{#model.id})",nativeQuery = true)
    int insert(@Param("model") MyCatUser model);

}
